/* v-fullScreen 全屏指令 */

export default {
	bind(el, binding, vnode, oldVnode) {
		el.style.cursor = "pointer";
		el.addEventListener("click", function () {
			let element = document.documentElement;
			// 全屏状态
			let isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;

			// 全屏方法
			let rfs = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;

			// 退出全屏
			let cfs = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen || document.msExitFullscreen;
			if (rfs && cfs) {
				isFullscreen ? cfs.call(document) : rfs.call(element);
			} else {
				alert("浏览器不支持全屏");
			}
		});
	},
};
